﻿using System.ComponentModel;
using System;
using System.Collections.Generic;
using SyringeControl.WinForms;

namespace SyringeControl.ControlSamples
{
    public class SampleModel : INotifyPropertyChanged
    {
        public SampleModel()
        {
            _stringField.Changed += InvokePropertyChanged;
            _boolField.Changed += InvokePropertyChanged;
            _selectedDate.Changed += InvokePropertyChanged;
            _listField.Changed += InvokePropertyChanged;
        }

        void InvokePropertyChanged(string propName)
        {
            var handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propName));
        }
        public event PropertyChangedEventHandler PropertyChanged;

        INotifyingProperty<string> _stringField = new SimpleProperty<string>("StringField");
        public string StringField
        {
            get { return _stringField.Get(); }
            set
            {
                _stringField.Set(value);
            }
        }

        INotifyingProperty<bool> _boolField = new SimpleProperty<bool>("BoolField");
        public bool BoolField
        {
            get { return _boolField.Get(); }
            set 
            { 
                _boolField.Set(value);
            }
        }

        ListProperty<DateTime> _listField = new ListProperty<DateTime>("ListField");
        public IList<DateTime> ListField
        {
            get { return _listField.Get(); }
            set 
            {
                _listField.Set(value);
            }
        }

        INotifyingProperty<DateTime> _selectedDate = new SimpleProperty<DateTime>("SelectedDate");
        public DateTime SelectedDate 
        {
            get { return _selectedDate.Get(); }
            set {
                _selectedDate.Set(value);
            }
        }
    }
}